﻿
Imports storoomc
Imports elpmis
Imports managedServer

Public Class configDelegate
    Inherits requestProcessor

    Public Const _pathidentity As String = "::__INVALID_PATH__::"

    Public Overrides Sub initial(Optional ByVal config As configParser = Nothing)
        MyBase.initial(config)
        If debugassert(Not config Is Nothing, "config is nothing.") Then
            If Not storage Is Nothing Then
                storage.close()
            End If
            storage = New storoomTalk()
            assert(storage.initial(config, configNaming.storage.section))
            If Not cache Is Nothing Then
                cache.close()
            End If
            cache = New storoomTalk()
            assert(cache.initial(config, configNaming.cache.section))
            lpmsengi.initial(config)
            loosenSPMLimit(ProHttpS.processorHttpServer().threadCount())
            insertSharedVariables()
            insertSharedFunctions()
        End If
    End Sub

    Private Shared Sub insertSharedVariables()
        For Each i As Reflection.FieldInfo In _
            GetType(query).GetFields(Reflection.BindingFlags.Public Or Reflection.BindingFlags.Static)
            sharedContext.insertVariable("query." + i.Name, typeDefination.string, i.GetValue(Nothing))
        Next
        sharedContext.insertVariable("path.login", typeDefination.string, login._pathidentity)
        sharedContext.insertVariable("path.register", typeDefination.string, register._pathidentity)
        sharedContext.insertVariable("path.usrk", typeDefination.string, usrk._pathidentity)
        sharedContext.insertVariable("path.apilogin", typeDefination.string, apilogin._pathidentity)
    End Sub

    Private Shared Sub insertSharedFunctions()
    End Sub

    Public Overrides Function pathidentity() As String
        Return _pathidentity
    End Function

    Public Overrides Function process(ByVal context As httpContext) As Boolean
        Return debugassert(False, "should not be able to call configDelegate.process")
    End Function
End Class
